#pragma once

#include "resource.h"

class CDbClearEdit : public CWindowImpl<CDbClearEdit, CEdit>
{
public:
	BEGIN_MSG_MAP(CSuperEdit)
		MESSAGE_HANDLER(WM_LBUTTONDBLCLK, OnLButtonDBClick)
	END_MSG_MAP()

	LRESULT OnLButtonDBClick(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		SetWindowText(_T(""));
		return 0;
	}
};


class CNewDLTask:
	public CAxDialogImpl<CNewDLTask>
{
public:
	enum{IDD = IDD_NEW_TASK_DLG};

	CNewDLTask(void);
	~CNewDLTask(void);

	BEGIN_MSG_MAP(CNewDLTask)
		MESSAGE_HANDLER(WM_INITDIALOG,OnInitDialog)
		MESSAGE_HANDLER(WM_CLOSE,OnClose)
		COMMAND_HANDLER(IDC_OK_BTN, BN_CLICKED, OnBnClickedBtnOk)
		COMMAND_HANDLER(IDC_CANCEL_BTN, BN_CLICKED, OnBnClickedCheckCancel)
		COMMAND_HANDLER(IDC_SaveBrowseBtn, BN_CLICKED, OnBnClickedSavebrowsebtn)
		COMMAND_HANDLER(IDC_UrlBrowseBtn, BN_CLICKED, OnBnClickedUrlbrowsebtn)
		COMMAND_HANDLER(IDC_ISFLORD_CHECK,BN_CLICKED,OnIsFlordBtnChecked);
	END_MSG_MAP()


	//MSG
	LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
	LRESULT OnClose(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
	LRESULT OnBnClickedBtnOk(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnBnClickedCheckCancel(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnIsFlordBtnChecked(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);

	download_info GetDownloadInfo();


private:
	BOOL  SetTextFormClipboard();
	CDbClearEdit m_urlEdit;
	
	ProxyType GetInternetAccessType();
	VOID	SetInternetAccessType(ProxyType type);
	
	ATL::CString GetFileNameByUrl(LPCTSTR lpFileName);

	ATL::CString GetUrlFromUrlEdit();

	
public:
	LRESULT OnBnClickedSavebrowsebtn(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnBnClickedUrlbrowsebtn(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);

private:
	download_info_def m_dlInfo;
};
